#include "logindialog.h"
#include "ui_logindialog.h"
#include "cnsGlobal.h"

CNS_INIT(LoginDialog)
CNS_REGISTER_COM_FACTORY(LoginDialog)
CNS_INIT_END

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
    ui->setupUi(this);
}

LoginDialog::~LoginDialog()
{
    delete ui;
}

QPushButton *LoginDialog::getBtnLogin()
{
    return ui->btnLogin;
}

QString LoginDialog::getUsername()
{
    return ui->ledtLoginID->text();
}

QString LoginDialog::getPasswd()
{
    return ui->ledtLoginPasswd->text();
}

void LoginDialog::on_btnCancel_clicked()
{
    qApp->closeAllWindows();
}

void LoginDialog::setUsername(const QString& username)
{
    ui->ledtLoginID->setText(username);
}

void LoginDialog::setPasswd(const QString& passwd)
{
    ui->ledtLoginPasswd->setText(passwd);
}

QLabel* LoginDialog::getLoginStatus()
{
    return ui->lbLoginStatus;
}

void LoginDialog::enable(bool enable)
{
    ui->btnLogin->setEnabled(enable);
}
